package com.cedar.model.Singleton;
/**
 * 同步方法实现单例模式
 * */
public class SingletonTest {
    private static SingletonTest instance = null;

    private SingletonTest() {}

    private static synchronized void syncInit() {
        if (instance == null) {
            instance = new SingletonTest();
        }
    }

    public static SingletonTest getInstance() {
        if (instance == null) {
            syncInit();
        }
        return instance;
    }
}
